import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    currentArea: 1, // 选择的类型
    // currentAreaCode:1,//默认全国
    currentProvince: 0, // 省份的code
    currentCity: 0, //市级code
    currentCounty: '', // 县名称
    countyCode: '', //县code
    school_id: 0, // 学校id
    allData: {},
    permission_name: '',
    currentfixed: 1,
    online_id: [],
    beginState: 1,// 判断是登陆进来的 点击下钻的
    school_listdata: [], // 存储不是学校级的学校
    mechanism_name: '',// 储存用户名
  },
  mutations: {
    // 当前行政区域--全国/省/市
    setCurrentArea(state, data) {
      state.currentArea = data
      switch (data) {
        case 1:
          state.currentProvince = 0
          state.currentCity = 0
          state.currentCounty = ''
          state.countyCode = ''
          state.school_id = 0
          break
        case 2:
          state.currentCity = 0
          state.currentCounty = ''
          state.countyCode = ''
          state.school_id = 0
          break
        case 3:
          state.currentCounty = ''
          state.countyCode = ''
          state.school_id = 0
          break
        case 4:
          state.school_id = 0
          break

        default:
          break
      }
    },
    setCurrentfixed(state, data) {
      state.currentfixed = data
    },
    setOnline_id(state, data) {
      state.online_id = data
    },
    setCurrentProvince(state, data) {
      state.currentProvince = data
    },
    setCurrentCity(state, data) {
      state.currentCity = data
    },
    setCurrentCounty(state, data) {
      state.currentCounty = data
    },
    setCountyCode(state, data) {
      state.countyCode = data
    },
    setSchoolId(state, data) {
      state.school_id = data
    },
    setAllData(state, data) {
      state.allData = data
    },
    setPermission_name(state, data) {
      state.permission_name = data
    },
    setBeginState(state, data) {
      state.beginState = data
    },
    setSchool_listdata(state, data) {
      state.school_listdata = data
    },
    setMechanism_name(state, data) {
      state.mechanism_name = data
    }
  },
  actions: {},
  modules: {}
})
